import type { IPostTemplate } from '@/interfaces';
import useContentLayer from '@/hooks/useContentLayer';
import { useContext } from 'react';
import { PostTemplateAdminContext } from '@/contexts/admin/forum/postTemplate';

export default function QueryPostTemplateContent({
  details,
}: {
  details: IPostTemplate;
}) {
  const context = useContext(PostTemplateAdminContext);
  const metadata = context.metadata!;

  useContentLayer({
    dep: details.content,
    metadata,
  });

  return (
    <div className="row">
      <div className="col">
        <div className="card">
          <div className="card-header bg-transparent text-muted">
            <i className="bi bi-card-text me-2"></i>
            内容
          </div>
          <div className="card-body">
            <div
              className="clearfix text-break content-layer"
              dangerouslySetInnerHTML={{ __html: details.content }}
            />
          </div>
        </div>
      </div>
    </div>
  );
}
